/**
 * @file webpack.config.js
 * @see webpack.github.io
 */

"use strict";

const path = require("path");
const webpack = require("webpack");
const NpmInstallPlugin = require('npm-install-webpack-plugin');

const DIRS = {
  src: path.join(__dirname, "src"),
  build: path.join(__dirname, "build")
};

module.exports = {
  entry:[ 
      'webpack-dev-server/client?http://localhost:8080',
      'webpack/hot/only-dev-server',
      // Application
      path.join(DIRS.src, "app", "index.jsx")
  ],
  output: {
    path: path.join(DIRS.build),
    publicPath: "build/",
    filename: "bundle.js"
  },
  module: {
    preLoaders: [{
      test: /\.jsx?$/,
      loaders: ["eslint"],
      exclude: /(node_modules|build|modernizr.js)/
    }],
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'react-hot!babel'
      }
    ]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  devServer: {
    contentBase: DIRS.build,
    hot: true,
    proxy: {
      '/doc': {
        target: "localhost:5000",
        secure: false
      }
    }
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new NpmInstallPlugin({
      save: true // --save
    })
  ]
};
